//
//  LLDay.swift
//  LiLi
//
//  Created by liuzhu on 2019/1/9.
//  Copyright © 2019 liuzhu. All rights reserved.
//

import UIKit
enum DayStatusEnum: Int{
    case DAYSTATUS_ACTION_MAIN = 10          //主事件
    case DAYSTATUS_ACTION_SUB = 12          //从事件(事件设定在其他日期，只不过按日，月，周等提醒的日期中包含今天）
    case DAYSTATUS_ACTION_MAIN_SUB = 13     //既包含主事件又包含从事件
    case DAYSTATUS_NOACTION = 15            //无事件
    case DAYSTATUS_NODATE = 20              //没有这天
    case DAYSTATUS_CURRENT = 30             //和当前日期一致
}

class LLDay: NSObject {
    var dateStr:String?                         //公历日期 xxxx-xx-xx
    var weekStr:String?                         //周几    1~7
    var chineseDateStr:String?                  //农历日期 xx-xx
    var chineseYear:String?                     //农历年 兔，狗......
    var dayStatus:DayStatusEnum = DayStatusEnum.DAYSTATUS_NODATE
    var status:Int32?                                              //1：已经通知过了，日期已过。0：还未通知或还未结束
    var actions:[LLAction] = [LLAction]()
    
    func saveAction(action:LLAction){
        var index = 0
        if actions.count == 0 {
            actions.append(action)
        }else{
            var isExis = false
            for i in 1...actions.count{
                let foraction = actions[i-1]
                if foraction.recordName! == action.recordName!{
                    isExis = true
                    index = i - 1
                }
            }
            if isExis{
                actions.remove(at: index)
                actions.append(action)
            }else{
                actions.append(action)
            }
        }
    }
    
    func deleteAction(action:LLAction){
        var index = 0
        var isExis = false
        for i in 1...actions.count{
            let foraction = actions[i-1]
            if foraction.recordName! == action.recordName!{
                isExis = true
                index = i - 1
            }
        }
        if isExis{
            actions.remove(at: index)
        }
    }
}
